////#include "MSM_SimulationRecorder.h"
//#include "MSM_SimulationRecording.h"
//#include "MSM_SimulationFrame.h"
//#include "MSM_RecordingEntry.h"
//#include "NodeState.h"
//
//Sx::Simulation::Recording::MSM_SimulationRecorder::MSM_SimulationRecorder() {
//	this->simulation = nullptr;
//	this->recording = new MSM_SimulationRecording();
//	this->activelyRecording = false;
//}
//
//Sx::Simulation::Recording::MSM_SimulationRecorder::~MSM_SimulationRecorder() {
//	/* this->simulation not owned by this class */
//	delete this->recording;
//	this->recording = nullptr;
//}
//
//bool Sx::Simulation::Recording::MSM_SimulationRecorder::setSimulation(Simulations::MassSpringSimulation* simulation) {
//	if ( simulation == nullptr ) {
//		std::cerr << "[MSM_SimulationRecorder:setSimulation] Error: Cannot set recorder simulation to nullptr." << std::endl;
//		return false;
//	}
//
//	this->simulation = simulation;
//	this->simulation->addListener(this);
//	return true;
//}
//
//void Sx::Simulation::Recording::MSM_SimulationRecorder::setRecording(bool recording) {
//	this->activelyRecording = recording;
//
//	if ( this->recording == nullptr ) return;
//	this->recording->setSimulation(this->simulation);
//}
//
//bool Sx::Simulation::Recording::MSM_SimulationRecorder::isRecording() const {
//	return this->activelyRecording;
//}
//
//void Sx::Simulation::Recording::MSM_SimulationRecorder::onConstruct() { return; }
//void Sx::Simulation::Recording::MSM_SimulationRecorder::preUpdate() { return; }
//
///* 
// * Main function for storing a mesh to a frame in a recording. This function
// * must be as FAST as possible.
// */
//bool StoreMeshToEntry(Sx::Simulation::Recording::MSM_RecordingEntry& entry, Sx::Simulation::Objects::MassSpringMesh* mesh) {
//	if ( mesh == nullptr ) return false;
//	
//	//--------------------------------------------------------------------------
//	// Assign the mesh that these states belong to.
//	//--------------------------------------------------------------------------
//	entry.mesh = mesh;
//
//	//--------------------------------------------------------------------------
//	// Store each p,v,a,f combination as a state inside the recording entry.
//	// This represents the state of each node in the mesh for the current frame.
//	//--------------------------------------------------------------------------
//	for ( unsigned int i = 0; i < mesh->getNodeCount(); i++ ) {
//		Sx::Simulation::States::NodeState& physicalState = entry.getNextNodeState();
//
//		Eigen::Vector3d& position = mesh->getNodePosition(i);
//		Eigen::Vector3d& velocity = mesh->getNodeVelocity(i);
//		Eigen::Vector3d& acceleration = mesh->getNodeAcceleraction(i);
//		Eigen::Vector3d& extForce = mesh->getNodeExternalForce(i);
//
//		//----------------------------------------------------------------------
//		// Store the position of the current node
//		//----------------------------------------------------------------------
//		physicalState.px = position.x();
//		physicalState.py = position.y();
//		physicalState.pz = position.z();
//
//		//----------------------------------------------------------------------
//		// Store the velocity of the current node
//		//----------------------------------------------------------------------
//		physicalState.vx = velocity.x();
//		physicalState.vy = velocity.y();
//		physicalState.vz = velocity.z();
//
//		//----------------------------------------------------------------------
//		// Store the acceleration of the current node
//		//----------------------------------------------------------------------
//		physicalState.ax = acceleration.x();
//		physicalState.ay = acceleration.y();
//		physicalState.az = acceleration.z();
//
//		//----------------------------------------------------------------------
//		// Store the external force acting on the node
//		//----------------------------------------------------------------------
//		physicalState.fx = extForce.x();
//		physicalState.fy = extForce.y();
//		physicalState.fz = extForce.z();
//	}
//
//	return true;
//}
//
//bool StoreMassSpringMeshToFrame(Sx::Simulation::Recording::MSM_SimulationFrame& frame, Sx::Simulation::Objects::MassSpringMesh* mesh) {
//	if ( mesh == nullptr ) {
//		std::cerr << "[MSM_SimulationRecorder:StoreMassSpringMeshToFrame] Error: Cannot store nullptr mass-spring mesh to frame." << std::endl;
//		std::cerr << "  Mesh not recorded to recording frame." << std::endl;
//		return false;
//	}
//
//	//--------------------------------------------------------------------------
//	// Get a new entry. Entries store the data related to a mesh for this frame.
//	//--------------------------------------------------------------------------
//	Sx::Simulation::Recording::MSM_RecordingEntry& entry = frame.getNextEntry();
//	StoreMeshToEntry(entry, mesh);
//
//	return true;
//}
//
//void Sx::Simulation::Recording::MSM_SimulationRecorder::postUpdate() {
//	//--------------------------------------------------------------------------
//	// If this recorder is not recording don't record a frame. The postUpdate()
//	// however will be called every frame even when this recorder is not
//	// recording. If its not recording then just return because there is nothing
//	// to do.
//	//--------------------------------------------------------------------------
//	if ( this->activelyRecording == false ) return;
//
//	if ( this->simulation == nullptr ) {
//		std::cerr << "[MSM_SimulationRecorder:postUpdate] Error: Cannot record from nullptr simulation." << std::endl;
//		std::cerr << "  This recorder must be provided with a valid simulation to record." << std::endl;
//		return;
//	}
//
//	if ( this->recording == nullptr ) {
//		std::cerr << "[MSM_SimulationRecorder:postUpdate] Error: Recorder internal recording structure has not been initialized (nullptr)." << std::endl;
//		std::cerr << "  Frame information cannot be saved without a recording." << std::endl;
//		return;
//	}
//	
//	//--------------------------------------------------------------------------
//	// Record a frame.
//	// Retrieve the next frame structure and fill it in with the
//	// new position, velocity, acceleration, and external force for each node
//	// of each mesh in the simulation.
//	//--------------------------------------------------------------------------
//	Sx::Simulation::Objects::MassSpringMesh* mesh = nullptr;
//	MSM_SimulationFrame& frame = this->recording->getNextFrame();
//	for ( unsigned int i = 0; i < this->simulation->getMeshCount(); i++ ) {
//		mesh = this->simulation->getMesh(i);
//		StoreMassSpringMeshToFrame(frame, mesh);
//	}
//}
//
//void Sx::Simulation::Recording::MSM_SimulationRecorder::preRender() { return; }
//void Sx::Simulation::Recording::MSM_SimulationRecorder::postRender() { return; }
//
//void Sx::Simulation::Recording::MSM_SimulationRecorder::onReset() {
//	// clear recording
//}
//
//void Sx::Simulation::Recording::MSM_SimulationRecorder::onPause() { return; }
//void Sx::Simulation::Recording::MSM_SimulationRecorder::onResume() { return; }
//
//Sx::Simulation::Recording::MSM_SimulationRecording* const Sx::Simulation::Recording::MSM_SimulationRecorder::getRecording() const {
//	return this->recording;
//}
